package club.hicode.daydayup.netty.udp.client2;

import io.netty.channel.Channel;

import java.util.concurrent.ConcurrentHashMap;

/**
 * Future的上下文对象
 * communication
 *
 * @author Liu Chunfu
 * @date 2018-07-09 下午8:12
 **/
public class CommunicationContext {

    private static Channel channel;

    private static final ConcurrentHashMap<String, SyncFuture> KV = new ConcurrentHashMap<>(10);


    public static void setChannel(Channel curChannel) {
        channel = curChannel;
    }

    public static Channel getChannel() {
        return channel;
    }

    public static void addFuture(String id, SyncFuture future) {
        KV.put(id, future);
    }

    public static SyncFuture getFuture(String id) {
        return KV.get(id);
    }

    public static void clear(String id) {
        KV.remove(id);
    }

}
